package com.hao.tx.service.impl;

import com.hao.tx.dao.AccountDAO;
import com.hao.tx.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * TODO
 *
 * @author 97472
 * @version 1.0
 * @date 2021/11/10 15:07
 */
@Service
@Transactional()
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountDAO accountDAO;

    // 账号2 给账号1 转账100
    public void transfer() {
        // 账号1加100
        accountDAO.addMoney();
//        转账出现意外，如异常
        int i = 1/0;
        // 账号2减100
        accountDAO.cutMoney();
    }
}
